Skip to content

Reject CR/LF and obs-fold in OCSP requests#10966

Merged
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
ejohnstown:upd-ocsp
Jul 23, 2026
Merged

Reject CR/LF and obs-fold in OCSP requests#10966
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
ejohnstown:upd-ocsp

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Description

The OpenSSL compatibility APIs copied caller-supplied strings into the outbound OCSP request verbatim, so an embedded newline split it into attacker-chosen header lines, and a header name starting with SP or HTAB folded into the preceding header's value. OpenSSL rejects these; the library's own fetch path already rejects CR/LF via wolfIO_DecodeUrl().

  • wolfSSL_OCSP_REQ_CTX_http(): reject CR/LF in op and path.
  • wolfSSL_OCSP_REQ_CTX_add1_header(): reject CR/LF in name and value.
  • wolfSSL_OCSP_REQ_CTX_add1_header(): reject a name starting with SP or HTAB, which RFC 7230 Section 3.2.4 treats as an obs-fold continuation of the previous header rather than a new header.
  • wolfSSL_OCSP_parse_url(): reject CR/LF anywhere in the URL, the likely source of a tainted path via a certificate's AIA extension.

Issue: ZD-21992

Testing

Added test cases for the change.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI review requested due to automatic review settings July 22, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request hardens the OpenSSL-compatibility OCSP request builder against HTTP request splitting by rejecting CR/LF and header obs-fold patterns in caller-supplied request components, aligning behavior with OpenSSL and existing wolfSSL URL decoding safeguards.

Changes:

  • Reject CR/LF anywhere in OCSP URLs parsed via wolfSSL_OCSP_parse_url().
  • Reject CR/LF in OCSP request line pieces (op, path) and in header name/value, and reject header names starting with SP/HTAB (obs-fold).
  • Add regression tests covering CR/LF and obs-fold injection attempts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/api.c Adds negative tests to ensure CR/LF and obs-fold inputs are rejected in OCSP URL parsing and request/header building.
src/ssl.c Adds early CR/LF rejection in wolfSSL_OCSP_parse_url() to prevent tainted host/path/port outputs.
src/ocsp.c Adds shared CR/LF validation helper and enforces CR/LF + leading SP/HTAB rejection in OCSP request building APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ocsp.c Outdated
@ejohnstown
ejohnstown force-pushed the upd-ocsp branch 2 times, most recently from c514320 to a50e939 Compare July 22, 2026 21:48
The OpenSSL compatibility APIs copied caller-supplied strings into the
outbound OCSP request verbatim, so an embedded newline split it into
attacker-chosen header lines, and a header name starting with SP or HTAB
folded into the preceding header's value. OpenSSL rejects these; the
library's own fetch path already rejects CR/LF via wolfIO_DecodeUrl().

* wolfSSL_OCSP_REQ_CTX_http(): reject CR/LF in op and path.
* wolfSSL_OCSP_REQ_CTX_add1_header(): reject CR/LF in name and value.
* wolfSSL_OCSP_REQ_CTX_add1_header(): reject a name starting with SP or
  HTAB, which RFC 7230 Section 3.2.4 treats as an obs-fold continuation
  of the previous header rather than a new header.
* wolfSSL_OCSP_parse_url(): reject CR/LF anywhere in the URL, the likely
  source of a tainted path via a certificate's AIA extension.

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JacobBarthelmeh
JacobBarthelmeh merged commit b3424c4 into wolfSSL:master Jul 23, 2026
342 of 343 checks passed
@ejohnstown
ejohnstown deleted the upd-ocsp branch July 23, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants